package chapter02;

public class Test08_Static {
    public static void main(String[] args) {
        StudentTwo s = new StudentTwo(101,"张三");
        s.info();
        System.out.println(s.getCount());
        StudentTwo s2 = new StudentTwo(102,"李四");
        System.out.println(s2.getCount());
        //可以使用类来调用
        System.out.println(StudentTwo.getCount());
    }
}
class StudentTwo{
    private int id;
    private String name;
    private String school = "河北建材";
    //由对象的属性变为类的属性 是所有对象共享的属性
    private static int count;
    //静态方法 属于类 对象共享
    public static int getCount(){
        return count;
    }
    public StudentTwo(int id,String name){
        this.id = id;
        this.name = name;
        this.count++;
    }
    public void info(){
        System.out.println("学号："+id);
        System.out.println("姓名："+name);
        System.out.println("学校："+school);
    }
}
